Page Faults in LFU | 您所在的位置:网站首页 › lfu page replacement algorithm in c programming › Page Faults in LFU |
Page Faults in LFU
C++Server Side ProgrammingProgramming
The Least Frequently Use aka LFU is a concept of page memory management, can also be used as a replacement algorithm. This process take a lead we the particular page needs a replacement when a new page is on the way by the process. LFU is one of the page replacement policy where an user can replace the least frequency of a particular operation page. If the page frequency is same in a process, then it will come first on the replacement list. Here we will take a page sequence of an array of pages denoted as pages[], whose length is N with a memory capacity of C. We need to evaluate the number of occurrence as page faults by imposing the algorithm mentioned below. Input for the LFU algorithm − N = 7, C = 3The pages taken for the process = { 1, 2, 3, 4, 2, 1, 5 } Output For The Process Is − Faults Occurrence In This Process = 6 Hits Needed For This Process = 1 Here the total capability of this particular process is here 3, which can save the max to max 3 pages in that allotted time in a memory location. Page 1 - It is required to run the process. As page 1 is not exist in the list, So, we can consider it as a page fault occurence: The value of page fault is = 1 Page 2 - It is needed for to run the process. Since page 2 is not exist in the list, So, we can consider it as a page fault occurence: The value of page fault is = 1 + 1 = 2 Page 3 - It is required to run the process. Since page 3 is not exist in the list, So, we can consider it as a page fault occurence: The value of page fault is =2 + 1 = 3 Page 4 - It is required to run the process. Since page 4 is not exist in the list, it replaces LFU page 1 : page fault = 3 + 1 = 4 Page 2 - It is required to run the process. Since page 2 is not exist in the list, So, we can not consider it as a page fault occurence: The value of page fault is = = 4 + 0 = 4 Continue the process.... Algorithm of the Page Faults in LFUThe LFU algorithm is a replacement process mentioned here in the field of operating system. This process always least frequently used pages present in the process. Step 1 − Initialize the process of LFU operation. Step 2 − Declare and mention the total count as 0. Step 3 − Create a vector class. Step 4 − Construct and declare an array with the desired array size. Step 5 − Start the process with the size of memory capacity. Step 6 − Create a map. Step 7 − Store the frequency value to the map of the pages. Step 8 − Traverse page elements. Step 9 − If; the desired element is available in that particular location in the memory, then erase and push it for next level. Step 10 − Step 9 increase the process frequency. Step 11 − Else; the main memory totally occupied; remove the initial element and decrease the possible frequency of the data. Step 12 − Count increase. Step 13 − Compare the frequency result. Step 14 − Sort the pages as per their frequency and time based result. Step 15 − If we get the same frequency, then the page will arrive at first. Step 16 − Repeat the process. Step 17 − Return the result. Step 18 − Terminate the process Syntax for the Page Faults in LFU int main() { int n,o,m,a,i,r,j,p,k,w; cout o; cout m; vector p(m); cout |
CopyRight 2018-2019 实验室设备网 版权所有 |